<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
</head>
<body>
<table border="1">
    <tr>
        <th>序号</th>
        <th>账户状态</th>
        <th>用户名称</th>
        <th>供货商名称</th>
        <th>归属地</th>
        <th>供应原料</th>
        <th>创建时间</th>
        <th>更新时间</th>

    </tr>
    @if (count($users) > 0)
        <?php $auth_user_id = auth()->user()->id ?>
        @foreach ($users as $k => $user)
            <tr>
                <td>{{ $k + 1 }}</td>
                <td >
                    {{$user->allow_login ? '正常' : '已禁用'}}
                </td>
                <td>{{ $user->username }}</td>
                <td>{{ $user->supplier->name }}</td>
                <td>{{ $user->area->name }}</td>
                <?php
                $supply_goods = $user->supplier->goods;
                $supply_goods = json_decode($supply_goods);
                $supply_goods_name = \App\Goods::whereIn('id', $supply_goods)->where('is_available', true)->whereNull('deleted_at')->lists('name');
                if ( ! empty($supply_goods_name)) {
                    $supply_goods_name = $supply_goods_name->toArray();
                } else {
                    $supply_goods_name = [];
                }
                ?>
                <td>{{ implode('；', $supply_goods_name) }}</td>
                <td>{{ $user->created_at }}</td>
                <td>{{ $user->edit_at }}</td>
            </tr>
        @endforeach
    @else
        <tr>
            <td class="text-center" colspan="8">没有找到供应商</td>
        </tr>
    @endif
</table>
</body>
</html>